<template>
  <div class="swiper">
    <swiper :options="swiperOptions" v-if="showSwiper">
      <!-- slides -->
      <swiper-slide v-for="item of list" :key="item.id">
        <img class="swiper-img" :src="item.imgUrl" />
      </swiper-slide>

      <!-- Optional controls -->
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>
<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOptions: {
        pagination: '.swiper-pagination',
        loop: true

      },
      swiperList: [{
        id: '001',
        imgurl: 'http://img1.qunarzz.com/sight/p0/201305/31/5d45aefbe558d610c8d65eac.jpg_600x330_003c57cf.jpg'
      },
      {
        id: '002',
        imgurl:
          'http://img1.qunarzz.com/sight/p0/201305/31/dadc50f610306532c8d65eac.jpg_600x330_d85e761a.jpg'
      }]

    }
  },
  computed: {
    showSwiper () {
      return this.list.length
    }
  }
}
</script>
<style lang="stylus" scoped>
.swiper >>>.swiper-pagination-bullet-active {
  background: #fff;
}

.swiper {
  overflow: hidden;
  width: 100%;
  height: 0;
  padding-bottom: 31.2%;
  background: #eee;

  .swiper-img {
    width: 100%;
  }
}
</style>
